const app = getApp();
Component({
  options: {
    styleIsolation: "apply-shared",
  },
  properties: {
    customTitle: {
      type: Boolean,
      value: false,
    },
    url: {
      type: String,
      value: "",
    },
    openType: {
      type: String,
      value: "navigateBack",
      validator(val) {
        return [
          "navigate",
          "redirect",
          "switchTab",
          "reLaunch",
          "navigateBack",
        ].includes(val);
      },
    },
  },
  data: {
    wrapStyle: "",
    marginRight: "",
  },
  lifetimes: {
    attached() {
      const {
        statusBarHeight,
        menuButton,
        windowWidth,
      } = app.globalData.systemInfo;
      const { top, height, width, right } = menuButton;
      const navBarHeight =
        (top - statusBarHeight) * 2 + height + statusBarHeight;
      const titleMarginRight = (windowWidth - right) * 2 + width;
      this.setData({
        marginRight: titleMarginRight + "px",
        wrapStyle: `height:${navBarHeight}px;padding-top:${statusBarHeight}px;`,
      });
    },
  },
  methods: {},
});
